package com.wwy.lease.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wwy.lease.model.enums.AppointmentStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;

/**
 * `Date`类型的字段在序列化成JSON字符串时，需要考虑两个点，分别是**格式**和**时区**。本项目使用JSON序列化框架为Jackson，具体配置如下
 *
 * - **格式**
 *   格式可按照字段单独配置，也可全局配置，下面分别介绍
 *   - **单独配置**
 *     在指定字段增加`@JsonFormat`注解，如下
 *     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 *     private Date appointmentTime;
 *   - **全局配置**
 *     在`application.yml`中增加如下内容
 *     spring:
 *       jackson:
 *         date-format: yyyy-MM-dd HH:mm:ss
 * - **时区**
 *   时区同样可按照字段单独配置，也可全局配置，下面分别介绍
 *   - **单独配置**
 *     在指定字段增加`@JsonFormat`注解，如下
 *     @JsonFormat(timezone = "GMT+8")
 *     private Date appointmentTime;
 *   - **全局配置**
 *     spring:
 *       jackson:
 *         time-zone: GMT+8
 * 推荐格式按照字段单独配置，时区全局配置。
 */
@Schema(description = "预约看房信息表")
@TableName(value = "view_appointment")
@Data
public class ViewAppointment extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Schema(description = "用户id")
    @TableField(value = "user_id")
    private Long userId;

    @Schema(description = "用户姓名")
    @TableField(value = "name")
    private String name;

    @Schema(description = "用户手机号码")
    @TableField(value = "phone")
    private String phone;

    @Schema(description = "公寓id")
    @TableField(value = "apartment_id")
    private Long apartmentId;

    @Schema(description = "预约时间")
    @TableField(value = "appointment_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date appointmentTime;

    @Schema(description = "备注信息")
    @TableField(value = "additional_info")
    private String additionalInfo;

    @Schema(description = "预约状态")
    @TableField(value = "appointment_status")
    private AppointmentStatus appointmentStatus;
}